How to change image dimensions of a generated image from Python?
To change the size of a generated image:

img = bpy.data.images.new('imageName',1024, 1024)

# ...

img.generated_width = 2048
img.generated_height = 2048


Otherwise, call image.scale(w, h) to preserve existing pixel data.