title: How to save solve this: saving images with PIL.Image
body: <p>The error occured when I want to save images with PIL.Image 
  the code is as following:</p>
  
  <pre><code>from PIL import Image
  generated = np.load('/home/jovyan/GROUP_SHARED/Kimi.Zhang/cutout.npy')
  generated = generated[:25, :, :, :]
  print('image_size', generated.shape)
  
  j = Image.fromarray(generated)
  for i in range(len(generated)):
      j.save('/home/jovyan/GROUP_SHARED/Kimi.Zhang/imagetest_' + str(i) +'.jpg')
  </code></pre>
  
  <p>"generated" contains 25 images and I want to save them one by one to jpg.</p>
  
  <p>The result is:</p>
  
  <h2>image_size (25, 3, 32, 32)</h2>
  
  <pre><code>KeyError                                  Traceback (most recent call last)
  /opt/conda/lib/python3.6/site-packages/PIL/Image.py in fromarray(obj, mode)
     2415             typekey = (1, 1) + shape[2:], arr['typestr']
  -&gt; 2416             mode, rawmode = _fromarray_typemap[typekey]
     2417         except KeyError:
  
  KeyError: ((1, 1, 32, 32), '&lt;f4')
  
  During handling of the above exception, another exception occurred:
  
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-45-00cdf704f05a&gt; in &lt;module&gt;()
        5 
        6 
  ----&gt; 7 j = Image.fromarray(generated)
        8 for i in range(len(generated)):
        9     j.save('/home/jovyan/GROUP_SHARED/Kimi.Zhang/imagetest_' + str(i) 
  + '.jpg')
  
  /opt/conda/lib/python3.6/site-packages/PIL/Image.py in fromarray(obj, mode)
     2417         except KeyError:
     2418             # print(typekey)
  -&gt; 2419             raise TypeError("Cannot handle this data type")
     2420     else:
     2421         rawmode = mode
  
  TypeError: Cannot handle this data type
  </code></pre>
  
  <p>Does anyone know how to solve this? 
  Thanks very much!</p>
  
  <p>addition:</p>
  
  <pre><code>  KeyError                                  Traceback (most recent call last)
   /opt/conda/lib/python3.6/site-packages/PIL/Image.py in fromarray(obj, mode)
     2415             typekey = (1, 1) + shape[2:], arr['typestr']
  -&gt; 2416             mode, rawmode = _fromarray_typemap[typekey]
     2417         except KeyError:
  
  KeyError: ((1, 1, 32), '&lt;f4')
  
  During handling of the above exception, another exception occurred:
  
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-47-1316bb4844f6&gt; in &lt;module&gt;()
        7 #j = Image.fromarray(generated)
        8 for i in range(len(generated)):
  ----&gt; 9     j = Image.fromarray(generated[i])
       10     j.save('/home/jovyan/GROUP_SHARED/Kimi.Zhang/imagetest_' + str(i) 
  + '.jpg')
       11 
  
  /opt/conda/lib/python3.6/site-packages/PIL/Image.py in fromarray(obj, mode)
     2417         except KeyError:
     2418             # print(typekey)
  -&gt; 2419             raise TypeError("Cannot handle this data type")
     2420     else:
     2421         rawmode = mode
  
   TypeError: Cannot handle this data type
  </code></pre>