We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error with RGBA images
https://huggingface.co/datasets/huggan/few-shot-skulls

```
Status code:   500
Exception:     Status500Error
Message:       cannot write mode RGBA as JPEG
```

reported by @NielsRogge 



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `services/worker/src/worker/models/column/image.py`
Content:
```
1 from typing import Any, List
2 
3 from datasets import Image
4 from PIL import Image as PILImage  # type: ignore
5 
6 from worker.models.asset import create_image_file
7 from worker.models.column.default import (
8     Cell,
9     CellTypeError,
10     ColumnInferenceError,
11     ColumnTypeError,
12     CommonColumn,
13 )
14 
15 
16 def check_value(value: Any) -> None:
17     if value is None:
18         return
19     if not isinstance(value, PILImage.Image):
20         raise CellTypeError("image cell must be a PIL image")
21 
22 
23 def infer_from_values(values: List[Any]) -> None:
24     for value in values:
25         check_value(value)
26     if values and all(value is None for value in values):
27         raise ColumnInferenceError("all the values are None, cannot infer column type")
28 
29 
30 class ImageColumn(CommonColumn):
31     def __init__(self, name: str, feature: Any, values: List[Any]):
32         if feature:
33             if not isinstance(feature, Image):
34                 raise ColumnTypeError("feature type mismatch")
35         else:
36             infer_from_values(values)
37         self.name = name
38         self.type = "RELATIVE_IMAGE_URL"
39 
40     def get_cell_value(self, dataset_name: str, config_name: str, split_name: str, row_idx: int, value: Any) -> Cell:
41         if value is None:
42             return None
43         check_value(value)
44         # this function can raise, we don't catch it
45         return create_image_file(dataset_name, config_name, split_name, row_idx, self.name, "image.jpg", value)
46
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/services/worker/src/worker/models/column/image.py b/services/worker/src/worker/models/column/image.py
--- a/services/worker/src/worker/models/column/image.py
+++ b/services/worker/src/worker/models/column/image.py
@@ -41,5 +41,15 @@
         if value is None:
             return None
         check_value(value)
-        # this function can raise, we don't catch it
-        return create_image_file(dataset_name, config_name, split_name, row_idx, self.name, "image.jpg", value)
+        # attempt to generate one of the supported formats; if unsuccessful, throw an error
+        for ext in [".jpg", ".png"]:
+            try:
+                return create_image_file(
+                    dataset_name, config_name, split_name, row_idx, self.name, f"image{ext}", value
+                )
+            except OSError:
+                # if wrong format, try the next one, see https://github.com/huggingface/datasets-server/issues/191
+                #  OSError: cannot write mode P as JPEG
+                #  OSError: cannot write mode RGBA as JPEG
+                continue
+        raise ValueError("Image cannot be written as JPEG or PNG")

{"golden_diff": "diff --git a/services/worker/src/worker/models/column/image.py b/services/worker/src/worker/models/column/image.py\n--- a/services/worker/src/worker/models/column/image.py\n+++ b/services/worker/src/worker/models/column/image.py\n@@ -41,5 +41,15 @@\n         if value is None:\n             return None\n         check_value(value)\n-        # this function can raise, we don't catch it\n-        return create_image_file(dataset_name, config_name, split_name, row_idx, self.name, \"image.jpg\", value)\n+        # attempt to generate one of the supported formats; if unsuccessful, throw an error\n+        for ext in [\".jpg\", \".png\"]:\n+            try:\n+                return create_image_file(\n+                    dataset_name, config_name, split_name, row_idx, self.name, f\"image{ext}\", value\n+                )\n+            except OSError:\n+                # if wrong format, try the next one, see https://github.com/huggingface/datasets-server/issues/191\n+                #  OSError: cannot write mode P as JPEG\n+                #  OSError: cannot write mode RGBA as JPEG\n+                continue\n+        raise ValueError(\"Image cannot be written as JPEG or PNG\")\n", "issue": "Error with RGBA images\nhttps://huggingface.co/datasets/huggan/few-shot-skulls\r\n\r\n```\r\nStatus code:   500\r\nException:     Status500Error\r\nMessage:       cannot write mode RGBA as JPEG\r\n```\r\n\r\nreported by @NielsRogge \r\n\r\n\n", "before_files": [{"content": "from typing import Any, List\n\nfrom datasets import Image\nfrom PIL import Image as PILImage  # type: ignore\n\nfrom worker.models.asset import create_image_file\nfrom worker.models.column.default import (\n    Cell,\n    CellTypeError,\n    ColumnInferenceError,\n    ColumnTypeError,\n    CommonColumn,\n)\n\n\ndef check_value(value: Any) -> None:\n    if value is None:\n        return\n    if not isinstance(value, PILImage.Image):\n        raise CellTypeError(\"image cell must be a PIL image\")\n\n\ndef infer_from_values(values: List[Any]) -> None:\n    for value in values:\n        check_value(value)\n    if values and all(value is None for value in values):\n        raise ColumnInferenceError(\"all the values are None, cannot infer column type\")\n\n\nclass ImageColumn(CommonColumn):\n    def __init__(self, name: str, feature: Any, values: List[Any]):\n        if feature:\n            if not isinstance(feature, Image):\n                raise ColumnTypeError(\"feature type mismatch\")\n        else:\n            infer_from_values(values)\n        self.name = name\n        self.type = \"RELATIVE_IMAGE_URL\"\n\n    def get_cell_value(self, dataset_name: str, config_name: str, split_name: str, row_idx: int, value: Any) -> Cell:\n        if value is None:\n            return None\n        check_value(value)\n        # this function can raise, we don't catch it\n        return create_image_file(dataset_name, config_name, split_name, row_idx, self.name, \"image.jpg\", value)\n", "path": "services/worker/src/worker/models/column/image.py"}], "after_files": [{"content": "from typing import Any, List\n\nfrom datasets import Image\nfrom PIL import Image as PILImage  # type: ignore\n\nfrom worker.models.asset import create_image_file\nfrom worker.models.column.default import (\n    Cell,\n    CellTypeError,\n    ColumnInferenceError,\n    ColumnTypeError,\n    CommonColumn,\n)\n\n\ndef check_value(value: Any) -> None:\n    if value is None:\n        return\n    if not isinstance(value, PILImage.Image):\n        raise CellTypeError(\"image cell must be a PIL image\")\n\n\ndef infer_from_values(values: List[Any]) -> None:\n    for value in values:\n        check_value(value)\n    if values and all(value is None for value in values):\n        raise ColumnInferenceError(\"all the values are None, cannot infer column type\")\n\n\nclass ImageColumn(CommonColumn):\n    def __init__(self, name: str, feature: Any, values: List[Any]):\n        if feature:\n            if not isinstance(feature, Image):\n                raise ColumnTypeError(\"feature type mismatch\")\n        else:\n            infer_from_values(values)\n        self.name = name\n        self.type = \"RELATIVE_IMAGE_URL\"\n\n    def get_cell_value(self, dataset_name: str, config_name: str, split_name: str, row_idx: int, value: Any) -> Cell:\n        if value is None:\n            return None\n        check_value(value)\n        # attempt to generate one of the supported formats; if unsuccessful, throw an error\n        for ext in [\".jpg\", \".png\"]:\n            try:\n                return create_image_file(\n                    dataset_name, config_name, split_name, row_idx, self.name, f\"image{ext}\", value\n                )\n            except OSError:\n                # if wrong format, try the next one, see https://github.com/huggingface/datasets-server/issues/191\n                #  OSError: cannot write mode P as JPEG\n                #  OSError: cannot write mode RGBA as JPEG\n                continue\n        raise ValueError(\"Image cannot be written as JPEG or PNG\")\n", "path": "services/worker/src/worker/models/column/image.py"}]}