Generated image data disappears
You want to pack the image into the blend "file" right after you set the pixels.
I'm not sure if otherwise it's expectable that the data is lost over time (it definitely is if you close and reopen Blender), but I guess it's just kept in volatile memory if you don't pack it.

You can do so by simply calling

my_image.pack(as_png=True)


Note this doesn't mean the blend "file" itself has to be saved, it can in turn be an unsaved instance in memory.

The optional as_png=True is required as Blender otherwise tries to pack a file from disk and store its raw data in the blend, but not having a backing file and thus not knowing the file format, you have to tell it to simply pack it as if it would be an uncompressed PNG file (at least that's how I understood it).

This also makes it possible to mass-dump the generated images via File > External Data > Unpack All Into Files.

To detect if an image has been packed or is in volatile memory, open the UV/Image Editor, select the image in question, and check the text of the "Image" menu to the left of the image selector. If it is postfixed with a star (like Image*), you didn't pack it yet.