Make the code work with python 3.

In Python 3 you can't concat binary strings directly. We use bytearrays
instead.