prepare for python 3 and add unicode support to principals.