Added functionality to check that the image exists before trying to
recreate the image.