Item names may contain non-ascii characters

Encoded the item name in UTF-8 before using it to create the output files since it caused a crash if the item name contained non-ascii characters.