<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def download_url(url, destination):
 """ Download an external URL to the destination """

    from settings import VALID_IMAGE_EXTENSIONS
    base_name, ext = os.path.splitext(url)
    ext = ext.lstrip('.')

    if ext not in VALID_IMAGE_EXTENSIONS:
        raise Exception("Invalid image extension")

    base_path, filename = os.path.split(destination)
    os.makedirs(base_path)
    urllib.urlretrieve(url, destination)