Fixed UnicodeDecodeError in json encoding

Encodings other than utf-8 and ascii were not encoded in json, resulting in broken builds.

Fixes #9
Fixes #11
Closes #15