updated encode.c -- functions to convert to utf8