Bug 1019169: Fixed UTF <-> Uint8Array conversions

Fixes bug which caused multiple unit tests failures.