Allow setting encoding

Fixes #2.