Fix length calculation when encoding as binary
Merge pull request #11 from binlain/master

Fix length calculation when encoding as binary