check if temp_image exists before removing