def write_to_file(data: bytes, filepath: str) -> int:
    """ Writes arbitrary bytes to a file given `data` and `filepath`

        Returns number of `bytes` written
    """

    if not isinstance(data, bytes):
        raise TypeError("data expecting type bytes, got {0}".format(type(data)))
    if not isinstance(filepath, str):
        raise TypeError("data expecting type bytes, got {0}".format(type(data)))

    with open(filepath, "wb") as fd:
        return fd.write(data)