'Write array bytes to pickler file handle.
This function is an adaptation of the numpy write_array function
available in version 1.10.1 in numpy/lib/format.py.'

def write_array(self, array, pickler):

    buffersize = max(((16 * (1024 ** 2)) // array.itemsize), 1)
    if array.dtype.hasobject:
        pickle.dump(array, pickler.file_handle, protocol=2)
    else:
        for chunk in pickler.np.nditer(array, flags=['external_loop', 'buffered', 'zerosize_ok'], buffersize=buffersize, order=self.order):
            pickler.file_handle.write(chunk.tostring('C'))
