How to read and write image in python