Handle UTF-8 properly

Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1013347