Added Marshaler/Unmarshaler interfaces

This adds support for customised marshalling and
unmarshalling of user defined types as options.
Fixes #32.