Index: Shapely/tags/rel-1.0.13/shapely/geos.py
===================================================================
--- Shapely/tags/rel-1.0.13/shapely/geos.py	(revision 1458)
+++ Shapely/tags/rel-1.0.13/shapely/geos.py	(working copy)
@@ -3,7 +3,7 @@
 """
 
 import atexit
-from ctypes import cdll, CDLL, PyDLL, CFUNCTYPE, c_char_p
+from ctypes import cdll, CDLL, PyDLL, CFUNCTYPE, c_char_p, c_void_p
 from ctypes.util import find_library
 import os
 import sys
@@ -43,6 +43,8 @@
         raise ImportError, "Could not find geos_c library"
     lgeos = PyDLL(lib)
     free = CDLL(find_library('libc')).free
+    free.argtypes=[c_void_p]
+    free.restype=None
 else:
     # Try the major versioned name first, falling back on the unversioned name.
     try:
@@ -52,6 +54,8 @@
     except:
         raise
     free = CDLL('libc.so.6').free
+    free.argtypes=[c_void_p]
+    free.restype=None
 
 # Prototype the libgeos_c functions using new code from `tarley` in
 # http://trac.gispython.org/lab/ticket/189
Index: Shapely/tags/rel-1.0.13/shapely/ctypes_declarations.py
===================================================================
--- Shapely/tags/rel-1.0.13/shapely/ctypes_declarations.py	(revision 1458)
+++ Shapely/tags/rel-1.0.13/shapely/ctypes_declarations.py	(working copy)
@@ -23,6 +23,10 @@
     lgeos.GEOSGeomFromWKB_buf.restype = ctypes.c_void_p
     lgeos.GEOSGeomFromWKB_buf.argtypes = [ctypes.c_void_p, ctypes.c_size_t]
 
+    lgeos.GEOSGeomToWKB_buf.restype = ctypes.c_void_p
+    lgeos.GEOSGeomToWKB_buf.argtypes = [ctypes.c_void_p , ctypes.POINTER(ctypes.c_size_t)]
+
+
     lgeos.GEOSCoordSeq_create.restype = ctypes.c_void_p
     lgeos.GEOSCoordSeq_create.argtypes = [ctypes.c_uint, ctypes.c_uint]
 
Index: Shapely/tags/rel-1.0.13/shapely/geometry/base.py
===================================================================
--- Shapely/tags/rel-1.0.13/shapely/geometry/base.py	(revision 1458)
+++ Shapely/tags/rel-1.0.13/shapely/geometry/base.py	(working copy)
@@ -2,7 +2,7 @@
 Base geometry class and utilities.
 """
 
-from ctypes import string_at, byref, c_int, c_size_t, c_char_p, c_double
+from ctypes import string_at, byref, c_int, c_size_t, c_char_p, c_double, c_void_p
 import sys
 
 from shapely.geos import lgeos, free, allocated_c_char_p
@@ -349,13 +349,14 @@
     def to_wkb(self):
         """Returns a WKB byte string representation of the geometry."""
         func = lgeos.GEOSGeomToWKB_buf
-        size = c_int()
+        size = c_size_t()
         def errcheck(result, func, argtuple):
+            if not result: return None
             retval = string_at(result, size.value)[:]
             free(result)
             return retval
         func.errcheck = errcheck
-        return func(self._geom, byref(size))
+        return func(c_void_p(self._geom), byref(size))
 
     @exceptNull
     def to_wkt(self):
