Added utf8 encoding check to parse template