lm.py has a pb when some filename or dirname are not encoded with the default file system encoding. Please see a concrete case here.
One option, to allow lm to run smoothly is to avoid wrongly encoded files or directories (maybe with a warning message, asking to renames them).
What do you think?