read and writing an image