After this gets written, you should be using PIL to test that it's actually an image and not an arbitrary blob of binary data.