<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def be_array_to_bytes(arr):
 """ Writes an array to bytestring with big-endian data. """

    data = fix_byteorder(arr)
    if hasattr(arr, 'tobytes'):
        return data.tobytes()
    else:
        return data.tostring()