Allow images to be saved and loaded by id and repository

Fixes #2792