diff --git a/shopify/resources/image.py b/shopify/resources/image.py
index a0e82ef..b408261 100644
--- a/shopify/resources/image.py
+++ b/shopify/resources/image.py
@@ -23,7 +23,7 @@ class Image(ShopifyResource):
             return super(Image, self).__getattr__(name)
 
     def attach_image(self, data, filename=None):
-        self.attributes["attachment"] = base64.b64encode(data)
+        self.attributes["attachment"] = base64.b64encode(data).decode()
         if filename:
             self.attributes["filename"] = filename
 

Attaching Images - Decode required for Python 3 compatibility
When attaching an image from a local file:

```
with open("some_image.jpg","rb") as f:
    img = f.read()
    image1.attach_image(data=img)
```

img will be bytes while the attachment needs to be a string to the JSONified. So in image.py:

```
def attach_image(self, data, filename=None):
    self.attributes["attachment"] = base64.b64encode(data).decode() #decode() for Python 3
    if filename:
        self.attributes["filename"] = filename
```

I am not sure how to keep it Python 2 compatible.

diff --git a/test/image_test.py b/test/image_test.py
index 1234898..bde789e 100644
--- a/test/image_test.py
+++ b/test/image_test.py
@@ -1,5 +1,6 @@
 import shopify
 from test.test_helper import TestCase
+import base64
 
 class ImageTest(TestCase):
 
@@ -13,6 +14,19 @@ class ImageTest(TestCase):
         self.assertEqual('http://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1389388540', image.src)
         self.assertEqual(850703190, image.id)
 
+    def test_attach_image(self):
+        self.fake("products/632910392/images", method='POST', body=self.load_fixture('image'), headers={'Content-type': 'application/json'})
+        image = shopify.Image({'product_id':632910392})
+        image.position = 1
+        binary_in = base64.b64decode("R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3MNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf==")
+        image.attach_image(data=binary_in, filename='ipod-nano.png')
+        image.save()
+        binary_out = base64.b64decode(image.attachment)
+
+        self.assertEqual('http://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1389388540', image.src)
+        self.assertEqual(850703190, image.id)
+        self.assertEqual(binary_in, binary_out)
+
     def test_create_image_then_add_parent_id(self):
         self.fake("products/632910392/images", method='POST', body=self.load_fixture('image'), headers={'Content-type': 'application/json'})
         image = shopify.Image()

pip install -e .
parse_log_pytest
requirements.txt
pytest flake8 flake8_docstrings
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
flake8==7.2.0
flake8-docstrings==1.7.0
iniconfig==2.1.0
mccabe==0.7.0
packaging==24.2
pluggy==1.5.0
pyactiveresource==2.2.2
pycodestyle==2.13.0
pydocstyle==6.3.0
pyflakes==3.3.1
pytest==8.3.5
PyYAML==6.0.2
-e git+https://github.com/Shopify/shopify_python_api.git@c29e0ecbed9de67dd923f980a3ac053922dab75e#egg=ShopifyAPI
six==1.17.0
snowballstemmer==2.2.0
tomli==2.2.1

name: shopify_python_api
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - flake8-docstrings==1.7.0
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - packaging==24.2
      - pluggy==1.5.0
      - pyactiveresource==2.2.2
      - pycodestyle==2.13.0
      - pydocstyle==6.3.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pyyaml==6.0.2
      - six==1.17.0
      - snowballstemmer==2.2.0
      - tomli==2.2.1
prefix: /opt/conda/envs/shopify_python_api

test/image_test.py::ImageTest::test_attach_image
test/image_test.py::ImageTest::test_create_image test/image_test.py::ImageTest::test_create_image_then_add_parent_id test/image_test.py::ImageTest::test_get_image test/image_test.py::ImageTest::test_get_images test/image_test.py::ImageTest::test_get_metafields_for_image
shopify/resources/image.py
shopify/resources/image.py