Fixed possible deallocation of image.