Improve Python 3 compatibility (bytes vs str)