Fixed bug when an image is invalid.