file to image encoding and image to file decoding