diff --git a/Data/PEM.hs b/Data/PEM.hs
--- a/Data/PEM.hs
+++ b/Data/PEM.hs
@@ -8,10 +8,10 @@
 -- Read and write PEM files
 --
 module Data.PEM
-	( module Data.PEM.Types
+    ( module Data.PEM.Types
     , module Data.PEM.Writer
     , module Data.PEM.Parser
-	) where
+    ) where
 
 import Data.PEM.Types
 import Data.PEM.Writer
diff --git a/Data/PEM/Parser.hs b/Data/PEM/Parser.hs
--- a/Data/PEM/Parser.hs
+++ b/Data/PEM/Parser.hs
@@ -11,7 +11,7 @@
 -- A PEM contains contains from one to many PEM sections.
 -- Each section contains an optional key-value pair header
 -- and a binary content encoded in base64.
--- 
+--
 module Data.PEM.Parser
     ( pemParseBS
     , pemParseLBS
@@ -22,9 +22,10 @@
 import qualified Data.ByteString.Char8 as BC
 import qualified Data.ByteString.Lazy as L
 import qualified Data.ByteString.Lazy.Char8 as LC
-import qualified Data.ByteString.Base64.Lazy as Base64
 
 import Data.PEM.Types
+import Data.ByteArray.Encoding (Base(Base64), convertFromBase)
+import qualified Data.ByteArray as BA
 
 type Line = L.ByteString
 
@@ -51,23 +52,23 @@
                 getPemHeaderLoop (r:rs) = -- FIXME doesn't properly parse headers yet
                     Right ([], r:rs)
 
+        getPemContent :: String -> [(String,ByteString)] -> [BC.ByteString] -> [L.ByteString] -> Either (Maybe String) (PEM, [L.ByteString])
         getPemContent name hdrs contentLines lbs =
             case lbs of
                 []     -> Left $ Just "invalid PEM: no end marker found"
                 (l:ls) -> case endMarker `prefixEat` l of
                               Nothing ->
-                                  let content = Base64.decodeLenient l
-                                   in getPemContent name hdrs (content : contentLines) ls
+                                    case convertFromBase Base64 $ L.toStrict l of
+                                        Left err      -> Left $ Just ("invalid PEM: decoding failed: " ++ err)
+                                        Right content -> getPemContent name hdrs (content : contentLines) ls
                               Just n  -> getPemName (finalizePem name hdrs contentLines) n ls
         finalizePem name hdrs contentLines nameEnd lbs
             | nameEnd /= name = Left $ Just "invalid PEM: end name doesn't match start name"
             | otherwise       =
                 let pem = PEM { pemName    = name
                               , pemHeader  = hdrs
-                              , pemContent = toSBS $ L.concat $ reverse contentLines }
+                              , pemContent = BA.concat $ reverse contentLines }
                  in Right (pem, lbs)
-
-        toSBS = BC.concat . L.toChunks
 
         prefixEat prefix x =
             let (x1, x2) = L.splitAt (L.length prefix) x
diff --git a/Data/PEM/Types.hs b/Data/PEM/Types.hs
--- a/Data/PEM/Types.hs
+++ b/Data/PEM/Types.hs
@@ -8,13 +8,21 @@
 module Data.PEM.Types where
 
 import Data.ByteString (ByteString)
+import Basement.NormalForm
 
 -- | Represent one PEM section
 --
 -- for now headers are not serialized at all.
 -- this is just available here as a placeholder for a later implementation.
 data PEM = PEM
-        { pemName    :: String                 -- ^ the name of the section, found after the dash BEGIN tag.
-        , pemHeader  :: [(String, ByteString)] -- ^ optionals key value pair header
-        , pemContent :: ByteString             -- ^ binary content of the section
-        } deriving (Show,Eq)
+    { pemName    :: String                 -- ^ the name of the section, found after the dash BEGIN tag.
+    , pemHeader  :: [(String, ByteString)] -- ^ optionals key value pair header
+    , pemContent :: ByteString             -- ^ binary content of the section
+    } deriving (Show,Eq)
+
+instance NormalForm PEM where
+    toNormalForm pem =
+        toNormalForm (pemName pem) `seq` nfLbs (pemHeader pem) `seq` pemContent pem `seq` ()
+      where
+        nfLbs []         = ()
+        nfLbs ((s,bs):l) = toNormalForm s `seq` bs `seq` nfLbs l
diff --git a/Data/PEM/Writer.hs b/Data/PEM/Writer.hs
--- a/Data/PEM/Writer.hs
+++ b/Data/PEM/Writer.hs
@@ -16,7 +16,7 @@
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Char8 as BC
 import qualified Data.ByteString.Lazy as L
-import qualified Data.ByteString.Base64 as Base64
+import           Data.ByteArray.Encoding (Base(Base64), convertToBase)
 
 -- | write a PEM structure to a builder
 pemWrite :: PEM -> L.ByteString
@@ -33,7 +33,7 @@
           toHeader (k,v) = [ BC.pack k, ":", v, "\n" ]
           -- expect only ASCII. need to find a type to represent it.
           sectionName = BC.pack $ pemName pem
-          encodeLine l = Base64.encode l `B.append` "\n"
+          encodeLine l = convertToBase Base64 l `B.append` "\n"
 
           splitChunks b
                   | B.length b > 48 = let (x,y) = B.splitAt 48 b in x : splitChunks y
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2010-2012 Vincent Hanquez <vincent@snarc.org>
+Copyright (c) 2010-2018 Vincent Hanquez <vincent@snarc.org>
 
 All rights reserved.
 
diff --git a/README.md b/README.md
deleted file mode 100644
--- a/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-PEM haskell library
-===================
-
-Handle Privacy Enhanced Message (PEM) format.
diff --git a/pem.cabal b/pem.cabal
--- a/pem.cabal
+++ b/pem.cabal
@@ -1,25 +1,24 @@
 Name:                pem
-Version:             0.2.2
-Description:         Privacy Enhanced Mail (PEM) format reader and writer.
+Version:             0.2.4
+Synopsis:            Privacy Enhanced Mail (PEM) format reader and writer.
+Description:         Privacy Enhanced Mail (PEM) format reader and writer. long description
 License:             BSD3
 License-file:        LICENSE
 Copyright:           Vincent Hanquez <vincent@snarc.org>
 Author:              Vincent Hanquez <vincent@snarc.org>
 Maintainer:          Vincent Hanquez <vincent@snarc.org>
-Synopsis:            Privacy Enhanced Mail (PEM) format reader and writer.
 Build-Type:          Simple
 Category:            Data
 stability:           experimental
 Cabal-Version:       >=1.8
 Homepage:            http://github.com/vincenthz/hs-pem
-data-files:          README.md
 extra-source-files:  Tests/pem.hs
 
 Library
   Build-Depends:     base >= 3 && < 5
-                   , mtl
                    , bytestring
-                   , base64-bytestring >= 1.0.0
+                   , basement
+                   , memory
   Exposed-modules:   Data.PEM
   Other-modules:     Data.PEM.Parser
                      Data.PEM.Writer
