protected function writeImageFile(ImageInterface $image, ImagePathInterface $path) {
		$filename = sanitize_path(implode(DIRECTORY_SEPARATOR, [
		    $this->getOption('root'),
    		/**
    		 * The stack prefix is the part of the URL that is used to detect wich stack to trigger.
    		 * This implementation aims to store a file at the exact same URL so next requests could be served statically.
    		 */
		    $this->getOption('use_prefix', false) ? $path->getPrefix() : null,
		    $path->getPath(),
		]));
		$dirname = dirname($filename);
		if (!is_dir($dirname)) {
		    @mkdir($dirname, $this->getOption('mode', 0755), true);
			if (!is_dir($dirname)) {
    			throw new StorageBackendException(sprintf('Cannot create dir %s', $dirname), StorageBackendException::CANNOT_CREATE_DIR);
			}
		}
		if (!file_put_contents($filename, $image->getBinaryContent())) {
			throw new StorageBackendException(sprintf('Cannot write file %s', $filename), StorageBackendException::CANNOT_WRITE_FILE);
		}
	}