add unicode support

Base on the work of @yuanxu, make the code work for both python 2.7 and python 3.x.

Add a new test case for unicode string as well..