More exception handling

Fixed bugs:
If the window was resized before the image was set, an exception would
occur.
If there was only one image in the file list, deleting it wouldn't work.