Avoid making the image dirty when creating the undo group.
As per title