Fix bugs in encoder.js

These changes made the encoder work for me. Tested using the example in the README (with a 32-bit float PCM file instead of stdin) and it worked marvelously.