Custom encoder

#34

I'm not sure about this approach, however it works and not influence on public API. Let me know what you think.