Fix to deallocate the image.