Add function to FileUtils that encodes paths.

Use this function to properly set the source of images in ImageViewer.
Merge pull request #9190 from Mark-Simulacrum/issue-9117

Add encodeFilePath to FileUtils to convert file paths into encoded strings (replace metacharacters such as %, @, $, #, etc.)