Adding writeObject impl