create py3/2 conditional `to_unicode` func

This function is either `str` or `unicode`
depending on the Python version.