I want to give a mathematical answer rather than a legal answer. The legal experts may want to comment about what a judge would think about this, and Nicholas Psoras's answer already hints at it, but I can promise you this much: if they find it necessary, the prosecution will put on the stand an expert witness with impeccable credentials who will testify to what I write below, and the defence is not going to be able to find anyone reputable to testify to the opposite.
You are not going to get an illegal JPEG by chance. Of course, art is subjective, and a field of static (like a Jackson Pollock painting) can be interpreted as a pornographic image if one is so inclined, but a photorealistic depiction will not arise by chance. To be sure, it's not mathematically impossible, but it's far beyond any reasonable doubt; the qualified expert will be able to quantify how improbable we're talking about here better than I can, but we're not talking about one in a million, we're talking about one in a trillion trillion trillion.
As phoog commented under the original question, there's always a code that will turn your illegal file into something innocuous (or turn something innocuous into something illegal). But the information has to reside somewhere, and if you have a cryptography program that turns the text of Moby-Dick into an illegal image, then that program did not arise by chance; it was designed to do this. (In fact, the program should itself be illegal; it's really the image in an encrypted form, to which the text of Moby-Dick is merely the key.)
The sort of illegal number that comes up in cryptography (and in the Wikipedia article that inspired the cited question) is much shorter, although still not likely to arise by chance. Some of the things mentioned in the answers to that question, such as passwords and social-security numbers, are starting to get downright reasonable. (Getting a specific person's SSN by randomly picking 9 digits is still a one-in-a-billion long shot, but if you're writing down random numbers all day, then it can certainly happen.) But you don't seem to be asking about that, but rather about something that would be illegal in and of itself, without context. That requires all of the relevant information to be packed into that one number.
In short, if your defence is that the illegal image (assuming that we are talking about something like a photograph and not something like a password) appeared on your computer by chance as the result of harmless computer activity, then your defence is a lie (or at best an honest mistake about what was done with your computer). It may be interesting to know whether it would be a legally valid defence if true; after all, people have managed to fool juries (and judges) with lies before, and maybe the expert witness won't be believed. But the defence will be factually false.