Serializing objects in binary format