formatting image and cleanup