def _byte_pad(data, bound=4):
    """
    GLTF wants chunks aligned with 4 byte boundaries.
    This function will add padding to the end of a
    chunk of bytes so that it aligns with the passed
    boundary size.

    Parameters
    --------------
    data : bytes
      Data to be padded
    bound : int
      Length of desired boundary

    Returns
    --------------
    padded : bytes
      Result where: (len(padded) % bound) == 0
    """
    bound = int(bound)
    if len(data) % bound != 0:
        count = bound - len(data) % bound
        pad = (' ' * count).encode('utf-8')
        result = bytes().join([data, pad])
        if len(result) % bound != 0:
            raise ValueError('byte_pad failed! ori:{} res:{} pad:{} req:{}'
                .format(len(data), len(result), count, bound))
        return result
    return data
