Fix file name sanitization.

This better handles file names with dots in the path
and no file extension.

Fixes #344.
Merge pull request #346 from vcr/fix-issue-344

Fix file name sanitization.