diff --git a/Data/ByteString/Base64.hs b/Data/ByteString/Base64.hs
--- a/Data/ByteString/Base64.hs
+++ b/Data/ByteString/Base64.hs
@@ -42,7 +42,10 @@
 -- | Encode a string into base64 form.  The result will always be a
 -- multiple of 4 bytes in length.
 encode :: ByteString -> ByteString
-encode (PS sfp soff slen) = unsafePerformIO $ do
+encode (PS sfp soff slen)
+    | slen > maxBound `div` 4 =
+        error "Data.ByteString.Base64.encode: input too long"
+    | otherwise = unsafePerformIO $ do
   let dlen = ((slen + 2) `div` 3) * 4
   dfp <- mallocByteString dlen
   withForeignPtr alfaFP $ \aptr ->
diff --git a/README.markdown b/README.markdown
new file mode 100644
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1,37 @@
+# Fast base64 support
+
+This package provides a Haskell library for working with base64-encoded
+data quickly and efficiently, using the ByteString type.
+
+
+# Performance
+
+This library is written in pure Haskell, and it's fast:
+
+* 250 MB/sec encoding
+
+* 200 MB/sec strict decoding (per RFC 4648)
+
+* 100 MB/sec lenient decoding
+
+
+# Get involved!
+
+Please report bugs via the
+[bitbucket issue tracker](http://bitbucket.org/bos/base64-bytestring).
+
+Master [Mercurial repository](http://bitbucket.org/bos/base64-bytestring):
+
+* `hg clone http://bitbucket.org/bos/base64-bytestring`
+
+There's also a [git mirror](http://github.com/bos/base64-bytestring):
+
+* `git clone git://github.com/bos/base64-bytestring.git`
+
+(You can create and contribute changes using either Mercurial or git.)
+
+
+# Authors
+
+This library is written and maintained by Bryan O'Sullivan,
+<bos@serpentine.com>.
diff --git a/base64-bytestring.cabal b/base64-bytestring.cabal
--- a/base64-bytestring.cabal
+++ b/base64-bytestring.cabal
@@ -1,5 +1,5 @@
 name:                base64-bytestring
-version:             0.1.0.1
+version:             0.1.0.2
 synopsis:            Fast base64 encoding and deconding for ByteStrings
 description:         Fast base64 encoding and deconding for ByteStrings
 homepage:            http://bitbucket.org/bos/base64-bytestring
@@ -11,6 +11,7 @@
 copyright:           2010 Bryan O'Sullivan
 category:            Data
 build-type:          Simple
+extra-source-files:  README.markdown
 
 extra-source-files:
   tests/Transcode.hs
