1.用scipy
import scipy
scipy.misc.imsave('test.jpg', img)
2.用PIL
from PIL import Image
im = Image.fromarray(img)
im.save("test.jpg")