correctly saving modified images