Added check for file existance

This raises an exception when a user wants to embed base64 encoded image (File name too long - data:image/png;base64,iVBORw0KGgoAA...) into a page (to view in CI).
Fixing java unit test

For some reason, the class path in the backtrace has changed.
Merge pull request #674 from sponte/master

Added check for file existance