added check for image filetype, added check for key-existence before adding image (protocol forbids images without keys)