Modified javascript to use buffers. Bug fixes in library. Tested on OSX