Bencode routines in Erlang, converted from ssmith's darcs repository