Escape keys before converting to filenames.

Use encodeURIComponent to escape the '/' character.