def download_file(client, url, dest):
    """Download a file from the remote device

    This method handles the chunking needed to download a file from
    a given URL on the BIG-IP.

    Arguments:
        client (object): The F5RestClient connection object.
        url (string): The URL to download.
        dest (string): The location on (Ansible controller) disk to store the file.

    Returns:
        bool: True on success. False otherwise.
    """
    with open(dest, 'wb') as fileobj:
        chunk_size = 512 * 1024
        start = 0
        end = chunk_size - 1
        size = 0
        current_bytes = 0
        while True:
            content_range = '%s-%s/%s' % (start, end, size)
            headers = {'Content-Range': content_range, 'Content-Type':
                'application/octet-stream'}
            data = {'headers': headers, 'verify': False, 'stream': False}
            response = client.api.get(url, headers=headers, json=data)
            if response.status == 200:
                if size > 0:
                    current_bytes += chunk_size
                    fileobj.write(response.raw_content)
            if end == size:
                break
            crange = response.headers['Content-Range']
            if size == 0:
                size = int(crange.split('/')[-1]) - 1
                if chunk_size > size:
                    end = size
                continue
            start += chunk_size
            if current_bytes + chunk_size > size:
                end = size
            else:
                end = start + chunk_size - 1
    return True
