Add optional encoding parameter to byteStreamToString()

Also added tests.