Fixing some string/byte handling to make Python3 happy