Catch and log file errors when embedding images

Fixes #723.