title: TypeError: write() argument must be str, not bytes while saving .npy file
body: <p>I tried running the <a href="https://gist.github.com/fchollet/f35fbc80e066a49d65f1688a7e99f069" rel="noreferrer">code</a> in a <a href="https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html" rel="noreferrer">keras blog post.</a> </p>
  
  <p>The code writes to a .npy file as follows:</p>
  
  <pre><code>bottleneck_features_train = model.predict_generator(generator, nb_train_samples // batch_size)
  np.save(open('bottleneck_features_train.npy', 'w'),bottleneck_features_train)
  </code></pre>
  
  <p>It then reads from this file:</p>
  
  <pre><code>def train_top_model():
      train_data = np.load(open('bottleneck_features_train.npy'))
  </code></pre>
  
  <p>Now I get an error saying:</p>
  
  <pre><code>Found 2000 images belonging to 2 classes.
  Traceback (most recent call last):
    File "kerasbottleneck.py", line 103, in &lt;module&gt;
      save_bottlebeck_features()
    File "kerasbottleneck.py", line 69, in save_bottlebeck_features
      np.save(open('bottleneck_features_train.npy', 'w'),bottleneck_features_train)
    File "/opt/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py", line 511, in save
      pickle_kwargs=pickle_kwargs)
    File "/opt/anaconda3/lib/python3.6/site-packages/numpy/lib/format.py", line 565, in write_array
  version)
    File "/opt/anaconda3/lib/python3.6/site-packages/numpy/lib/format.py", line 335, in _write_array_header
  fp.write(header_prefix)
  TypeError: write() argument must be str, not bytes
  </code></pre>
  
  <p>After this, I tried changing the file mode from 'w' to 'wb'. This resulted in an error while reading the file:</p>
  
  <pre><code>Found 2000 images belonging to 2 classes.
  Found 800 images belonging to 2 classes.
  Traceback (most recent call last):
    File "kerasbottleneck.py", line 104, in &lt;module&gt;
      train_top_model()
    File "kerasbottleneck.py", line 82, in train_top_model
      train_data = np.load(open('bottleneck_features_train.npy'))
    File "/opt/anaconda3/lib/python3.6/site-packages/numpy/lib/npyio.py", line 404, in load
  magic = fid.read(N)
    File "/opt/anaconda3/lib/python3.6/codecs.py", line 321, in decode
  (result, consumed) = self._buffer_decode(data, self.errors, final)
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 0: invalid start byte
  </code></pre>
  
  <p>How can I fix this error?</p>