title: Python: How to write a single channel png file from numpy array?
body: <p>I want to write a single channel png image from a numpy array in python?
  In Matlab that would be </p>
  
  <pre><code>A = randi(100,100,255)
  imwrite(uint8(A),'myFilename.png','png');
  </code></pre>
  
  <p>I saw exampels using <code>from PIL import Image</code>  and <code>Image.fromarray()</code> but they are for jpeg and 3-channel pngs only it appears...  </p>
  
  <p>I already found the solution using opencv, I will post it here. Hopefully it will shorten someone else's searching...</p>