Allow non-image files to be uploaded

I reworked pull request #17 to allow non-image files to be uploaded.
It's far from perfect, but it works.
If you have any suggestions, please, tell me.