Encode strings as utf-8 when writing to binary file. Fixes #7