Reading an image and writing it again