title: How to write binary data to stdout in python 3?
body: <p>In python 2.x I could do this:</p>
  
  <pre><code>import sys, array
  a = array.array('B', range(100))
  a.tofile(sys.stdout)</code></pre>
  
  <p>Now however, I get a <code>TypeError: can't write bytes to text stream</code>. Is there some secret encoding that I should use?</p>