diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index baeea6b495e044ffe21bb6142e650569af5f1aa4..024a6656a150763f2086f9880425287f8db025ac 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -715,7 +715,7 @@ def image_from_array(ctx, ary, num_channels, mode="r", norm_int=False):
 
     if mode == "r":
         mode_flags = mem_flags.READ_ONLY
-    elif mode == "r":
+    elif mode == "w":
         mode_flags = mem_flags.WRITE_ONLY
     else:
         raise ValueError("invalid value '%s' for 'mode'" % mode)