added image save code