diff --git a/pyopencl/scan.py b/pyopencl/scan.py
index ee2b4e7a7e24352dbff0036c672f4a867aef7645..5a736fd6b3b84993895a7dca5dd738fc91e5646d 100644
--- a/pyopencl/scan.py
+++ b/pyopencl/scan.py
@@ -165,7 +165,7 @@ void ${name_prefix}_scan_intervals(
 
         local_fetch_expr_args = set(
             arg_name
-            for arg_name, ife_offsets in fetch_expr_offsets.iteritems()
+            for arg_name, ife_offsets in fetch_expr_offsets.items()
             if -1 in ife_offsets or len(ife_offsets) > 1)
     %>
 
@@ -758,7 +758,7 @@ def _make_template(s):
         from warnings import warn
         warn("leftover words in identifier prefixing: " + " ".join(leftovers))
 
-    return mako.template.Template(s, strict_undefined=True, disable_unicode=True)
+    return mako.template.Template(s, strict_undefined=True)
 
 from pytools import Record
 class _ScanKernelInfo(Record):
@@ -1265,7 +1265,7 @@ def copy_if(ary, predicate, extra_args=[], queue=None, preamble=""):
         is an on-device scalar (fetch to host with `count.get()`) indicating
         how many elements satisfied *predicate*.
     """
-    if len(ary) > np.iinfo(np.uint32):
+    if len(ary) > np.iinfo(np.uint32).max:
         scan_dtype = np.uint64
     else:
         scan_dtype = np.uint32
@@ -1334,7 +1334,7 @@ def partition(ary, predicate, extra_args=[], queue=None, preamble=""):
         is an on-device scalar (fetch to host with `count.get()`) indicating
         how many elements satisfied the predicate.
     """
-    if len(ary) > np.iinfo(np.uint32):
+    if len(ary) > np.iinfo(np.uint32).max:
         scan_dtype = np.uint64
     else:
         scan_dtype = np.uint32
@@ -1395,7 +1395,7 @@ def unique(ary, is_equal_expr="a == b", extra_args=[], queue=None, preamble=""):
         how many elements satisfied the predicate.
     """
 
-    if len(ary) > np.iinfo(np.uint32):
+    if len(ary) > np.iinfo(np.uint32).max:
         scan_dtype = np.uint64
     else:
         scan_dtype = np.uint32
diff --git a/test/test_array.py b/test/test_array.py
index d490aa8714b03369932035c671b750845f84ee31..a78e2334112c58474755dba926e2993e1115753c 100644
--- a/test/test_array.py
+++ b/test/test_array.py
@@ -677,7 +677,7 @@ def test_dot(ctx_factory):
 
     for a_dtype in dtypes:
         for b_dtype in dtypes:
-            print a_dtype, b_dtype
+            print(a_dtype, b_dtype)
             a_gpu = general_clrand(queue, (200000,), a_dtype)
             a = a_gpu.get()
             b_gpu = general_clrand(queue, (200000,), b_dtype)
@@ -943,7 +943,7 @@ def test_segmented_scan(ctx_factory):
                 seg_boundaries_values = []
                 for i in range(10):
                     seg_boundary_count = max(2, min(100, randrange(0, int(0.4*n))))
-                    seg_boundaries = [randrange(n) for i in xrange(seg_boundary_count)]
+                    seg_boundaries = [randrange(n) for i in range(seg_boundary_count)]
                     if n >= 1029:
                         seg_boundaries.insert(0, 1028)
                     seg_boundaries.sort()