docs: def _save_image(self, image_id, directory):
          """ Saves the image as a tar archive under specified name """
  
          for x in [0, 1, 2]:
              self.log.info("Saving image %s to %s directory..." %
                            (image_id, directory))
              self.log.debug("Try #%s..." % (x + 1))
  
              try:
                  image = self.docker.get_image(image_id)
  
                  if docker.version_info[0] < 3:
                      # Docker library prior to 3.0.0 returned the requests
                      # object directly which cold be used to read from
                      self.log.debug("Extracting image using HTTPResponse object directly")
                      self._extract_tar(image, directory)
                  else:
                      # Docker library >=3.0.0 returns iterator over raw data
                      self.log.debug("Extracting image using iterator over raw data")
  
                      fd_r, fd_w = os.pipe()
  
                      r = os.fdopen(fd_r, 'rb')
                      w = os.fdopen(fd_w, 'wb')
  
                      extracter = threading.Thread(target=self._extract_tar, args=(r,directory))
                      extracter.start()
  
                      for chunk in image:
                          w.write(chunk)
  
                      w.flush()
                      w.close()
  
                      extracter.join()
                      r.close()
                  self.log.info("Image saved!")
                  return True
              except Exception as e:
                  self.log.exception(e)
                  self.log.warn(
                      "An error occured while saving the %s image, retrying..." % image_id)
  
          raise SquashError("Couldn't save %s image!" % image_id)