Implement #1996 "PDF template should cache images"

- very simple cache for the duration of the PDF production
- takes care in particular of images used for checkboxes
- this with internal requests yield about 30% improvement in one example