python2 and python3 compatible utf8 encode and decode