fix UnicodeEncodeError when using `alias()` with Unicode text

I'm not a python expert, please suggest improvements where appropriate.