use sys.set_default_encoding for python2.x and other minor fixes for
unicode