code for picture saving