Add `Encoder` type for custom encoding of values

This PR allows users to implement an `Encoder` interface and `EncodeValues` function for datatypes where custom encoding of data values is required (ala the `Marshaler` in `encoding/json`)