use python2 and python3 compatible unicode and open functions