title: write numpy ndarray to Image
body: <p>I'm trying to read a binary file (8 bit RGB tuples) in Python, do some conversion on it and then write it as a png image. I'm doing the following:</p>
  
  <pre><code>typeinfo = np.dtype('&gt;i1' ) #read single bytes
  data=np.fromfile(("f%05d.txt" %(files[ctr])),dtype=typeinfo)
  data=np.reshape(data,[linesperfile,resX,3]) #reshape to size/channels
  </code></pre>
  
  <p>If I display the type information of <code>data</code> it says:</p>
  
  <pre><code>&lt;type 'numpy.ndarray'&gt;
  (512L, 7456L, 3L)
  </code></pre>
  
  <p>Then I do some manipulation on the image (in-place), afterwards I want to write the Image to a file. Currently I use:</p>
  
  <pre><code>import PIL.Image as im
  svimg=im.fromarray(data)
  svimg.save(("im%05d"%(fileno)),"png")
  </code></pre>
  
  <p>but it keeps giving me the following error:</p>
  
  <pre><code>line 2026, in fromarray
  raise TypeError("Cannot handle this data type")
  TypeError: Cannot handle this data type
  </code></pre>
  
  <p>Any ideas how to do this?</p>