JCLOUDS-331 - support specifying an imageChooser function in TemplateBuilder

Includes fix in ca8289b contributed by Martin Harris