More robust conversion to unicode

Fixes #72.