Allow policy-based serialization

An explicit Policy parameter allows to customize serialization of types
without having to modify them, which is useful if the types are supplied
by a library or if different serializations are needed.

Signed-off-by: Luca Niccoli <l.niccoli@awtech.it>