Javascript encoding and decoding erlang binary term