read and write image