Add encoding support

Closes #22