A bunch of fiddling to make uploaded image generation work asynchronously