adding image saving function