Fixed check for whether an image actually exists.