Add UTF-8 support to avatar function. Fixes #305