Code more defensively in image views/forms

Fixes bug 1229090 and fixes bug 1220315

Change-Id: I86636ea855e969abd65b5df6c3cf8ea0ff66dc28
Merge "Code more defensively in image views/forms"