Better support for types implementing Externalizable

Adds macros for generating ObjectInput and ObjectOutput instances.