Using this code to take a string and convert it to binary:
bin(reduce(lambda x, y: 256*x+y, (ord(c) for c in \'hello\'), 0))
this outputs:<
Are you looking for the code to do it or understanding the algorithm?
Does this do what you need? Specifically a2b_uu and b2a_uu? There are LOTS of other options in there in case those aren't what you want.
a2b_uu
b2a_uu
(NOTE: Not a Python guy but this seemed like an obvious answer)