Allow setting encoding

Not sure if this is the best way, but something like it.
I was thinking the encoding option is just passed to this. With defaulting to utf8.