--- _tkagg.cpp	2007-11-30 13:36:25.000000000 +1100
+++ _tkagg.cpp.new	2008-05-15 13:04:43.000000000 +1000
@@ -12,6 +12,8 @@
 #include <Python.h>
 #include <stdlib.h>
 
+#include <sstream>
+
 #include "agg_basics.h"
 #include "_backend_agg.h"
 #include "_transforms.h"
@@ -53,6 +55,10 @@
 
     long mode;
     long nval;
+
+    // temporary ulong to hold argv pointer values
+    unsigned long tmpulong;
+
     if (Tk_MainWindow(interp) == NULL) {
         // Will throw a _tkinter.TclError with "this isn't a Tk application"
         return TCL_ERROR;
@@ -71,7 +77,11 @@
         return TCL_ERROR;
     }
     /* get array (or object that can be converted to array) pointer */
-    aggo = (PyObject*)atol(argv[2]);
+
+    std::stringstream ulongss;  
+    ulongss.str(argv[2]);
+    ulongss >> tmpulong;
+    aggo = (PyObject*)tmpulong;
     RendererAgg *aggRenderer = (RendererAgg *)aggo;
     int srcheight = (int)aggRenderer->get_height();
 
@@ -85,7 +95,10 @@
     }
 
     /* check for bbox/blitting */
-    bboxo = (PyObject*)atol(argv[4]);
+    std::stringstream ulongss2;  
+    ulongss2.str(argv[4]);
+    ulongss2 >> tmpulong;
+    bboxo = (PyObject*)tmpulong;
     if (bboxo != Py_None) {
       bbox = (Bbox*)bboxo;
       l = bbox->ll_api()->x_api()->val();
