added function to pack image to save