docs: def download_file(image_name, output_path, width=DEFAULT_WIDTH):
      """Download a given Wikimedia Commons file."""
      image_name = clean_up_filename(image_name)
      logging.info("Downloading %s with width %s", image_name, width)
      try:
          contents, output_file_name = get_thumbnail_of_file(image_name, width)
      except RequestedWidthBiggerThanSourceException:
          logging.warning("Requested width is bigger than source - downloading full size")
          contents, output_file_name = get_full_size_file(image_name)
      output_file_path = os.path.join(output_path, output_file_name)
      try:
          with open(output_file_path, 'wb') as f:
              logging.debug("Writing as %s", output_file_path)
              f.write(contents)
          return output_file_path
      except IOError, e:
          msg = 'Could not write file %s on disk to %s: %s' % \
                (image_name, output_path, e.message)
          logging.error(msg)
          raise CouldNotWriteFileOnDiskException(msg)
      except Exception, e:
          logging.critical(e.message)
          msg = 'An unexpected error occured when downloading %s to %s: %s' % \
                (image_name, output_path, e.message)
          raise DownloadException(msg)