Fix crash in logging when filename contains non-ascii characters.

This is a fix for issue #239. I'm not sure if it's the best way to handle the types with your compat module but it seems to work for me.