port from/toBuffer and from/toHex from bitcoinjs-lib

original commits are by @dcousens. See bitcoinjs/bitcoinjs-lib#150
add test script
removes transitionary array handling

also remove number type checking
and better argument name
Merge pull request #1 from weilu/to-from-buffer-hex

To/from buffer/hex