What about a different idea: since the problem is the hardcoding of RasterImage, we could replace it by code like the following.
After thinking about this solution again i found a crash one case: If there is no Template definition in the user defined external_templates file then the line
templatename_ = etm.getTemplates().begin()->first; triggers a crash. Bernhard