An answer using PIL (just in case it's useful).
given a numpy array "A":
from PIL import Image
im = Image.fromarray(A)
im.save("your_file.jpeg")
you can replace "jpeg" with almost any format you want. More details about the formats here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…