build: fix encoding a typed array in the browser

The "length" hack I was doing doesn't work in real web browsers.

The Node.js implementation of the ArrayBuffer is non-standard
in that it allows bytes to be accessed via index.

In real web browsers you need to wrap the ArrayBuffer
with a Uint8Array, which properly includes the "length" property.