Consistently use __getstate__, __setstate__ pair for serializing

Previously, if __getstate__ was present in an object, it would be used
for serialization, but __setstate__ would only be used if object is
Persistent.