serializing object to read and write