diff --git a/Graphics/GD.hsc b/Graphics/GD.hsc
--- a/Graphics/GD.hsc
+++ b/Graphics/GD.hsc
@@ -42,7 +42,7 @@
 
 import Control.Exception (bracket)
 import Control.Monad (liftM, unless)
-import qualified Data.ByteString.Base as B
+import qualified Data.ByteString.Internal as B
 import Foreign
 import Foreign.C
 import Foreign.ForeignPtr
@@ -378,7 +378,7 @@
 
 dataByteString :: (Ptr CInt -> IO (Ptr a)) -> IO B.ByteString
 dataByteString f = alloca $ \szPtr -> do datPtr <- f szPtr >>= newForeignPtr gdFree . castPtr
-                                         liftM (B.fromForeignPtr datPtr . fromIntegral) (peek szPtr)
+                                         liftM (B.fromForeignPtr datPtr 0 . fromIntegral) (peek szPtr)
                                        
 --
 -- * Getting information about images.
diff --git a/gd.cabal b/gd.cabal
--- a/gd.cabal
+++ b/gd.cabal
@@ -1,21 +1,31 @@
 Name: gd
-Version: 3000.3.0
+Version: 3000.4.0
+Cabal-version: >= 1.2
+Build-type: Simple
 Copyright: Bjorn Bringert
 Maintainer: bjorn@bringert.net
 Author: Bjorn Bringert
 License: BSD3
-build-depends: base
-Extensions: ForeignFunctionInterface
 Synopsis: A Haskell binding to a subset of the GD graphics library
 Description:
   This is a binding to a (currently very small) subset of
   the GD graphics library.
-Exposed-Modules: Graphics.GD
-ghc-options: -O2 -Wall -fffi
-extra-libraries: gd, png, z, jpeg, m, fontconfig, freetype, pthread, expat
-includes: gd.h
-include-dirs:        cbits
-install-includes: gd-extras.h
-c-sources:           cbits/gd-extras.c
-extra-source-files:  cbits/gd-extras.h
-cc-options: -O2 
+Extra-source-files:  cbits/gd-extras.h
+
+Flag bytestring-in-base
+
+Library
+  if flag(bytestring-in-base)
+    -- bytestring was in base-2.0 and 2.1.1
+    Build-depends: base >= 2.0 && < 2.2
+  else
+    -- in base 1.0 and 3.0 bytestring is a separate package
+    Build-depends: base < 2.0 || >= 3, bytestring >= 0.9
+  Extensions: ForeignFunctionInterface
+  Exposed-Modules: Graphics.GD
+  Ghc-options: -Wall
+  Extra-libraries: gd, png, z, jpeg, m, fontconfig, freetype, pthread, expat
+  Includes: gd.h
+  Include-dirs:        cbits
+  Install-includes: gd-extras.h
+  C-sources:           cbits/gd-extras.c
