Fix error with unicode characters in database queries.

I'm not sure whether I should make this a config option. I mean
everyone is using UTF-8 now, right? RIGHT?
Escape the path we look for when creating the database query.