Fixing encode

Apparently there is some incorret/old typed arrays API used in `encode` function. Could you publish an update to npmjs.org if everything works?