title: Convert numpy array to hex bytearray
body: <p>I want to convert a numpy array to a bytestring in python 2.7. Lets say my numpy array <code>a</code> is a simple <code>2x2</code> array, looking like this:</p>
  
  <pre><code>[[1,10],
   [16,255]]
  </code></pre>
  
  <p>My question is, how to convert this array to a string of bytes or bytearray with the output looking like:</p>
  
  <pre><code>\x01\x0A\x10\xff
  </code></pre>
  
  <p>or equally well:</p>
  
  <pre><code>bytearray(b'\x01\x0A\x10\xff')
  </code></pre>