This is a generic principle regardless of what language/technique. The best way to combat this is to allow the human to check! In short, there would be a lot of work involved, for instance, how can you tell if the image is nude or child pornography by examining the pixels - it cannot be done as there would be a level of sophistication involved, like, there is a trial at the moment in my country for mobile operators to automatically block images being sent across in order to clamp down on pornography, just don't ask me how - but apparently reports of it are successful, I just would not trust whatever algorithm they have used as it may/could generate false positives!
This is quite a similar thing to the usage of Captcha, to block spammers, only the human would have to enter a magic word(s) or number(s) in such way that the analysis of the image will deduce what the image will contain thereby stopping the flow of spammers.
In your case, perhaps, prevent the upload of images, nahh, that's a bit too restricted, do what this site is doing - moderating. You need to moderate the images first (perhaps a queue or a safe holding directory to store the images) and decide if they are suitable or not.
If not, depending on the seriousness of the image - this could involve contacting the ISP and the local law enforcements (this is where the grey area happens - how would you know and not over-react?)....
It would pay to be wise, prudent and just alert the authorities in that case, if it's pornographic nature, inform the ISP, pass the buck onto them, and let them in turn decide the best course of action OR inform a local authority website that reports this kind of thing...like in my country, we have a link to the hotline web-site where people can anonymously post an email to the site and inform that they have encountered a pornographic image...
I am not a lawyer...but IIRC, and this is where the matter can stink up, you can view them, but to download them is illegal...again I have to post this disclaimer - I am not a lawyer, you need to check first....this is what I mean by where the grey area happens...
So in a nutshell, no one is above a computer, and there is a more smarter entity than a computer itself, i.e. a human moderator can only check and ascertain first prior to viewing the image...
Hope this helps,
Best regards,
Tom.