Templated version - with image IO