Python 3 compatibility: join using bytes rather than str
Python 3 compability: don't compare int to str