Allow arbitrary serialization function