diff --git a/Text/ProjectTemplate.hs b/Text/ProjectTemplate.hs
--- a/Text/ProjectTemplate.hs
+++ b/Text/ProjectTemplate.hs
@@ -21,7 +21,8 @@
 import qualified Data.ByteString.Base64    as B64
 import           Data.Typeable             (Typeable)
 import           Filesystem                (createTree)
-import           Filesystem.Path.CurrentOS (directory, encode, fromText, toText)
+import           Filesystem.Path.CurrentOS (directory, fromText, toText)
+import qualified Data.Conduit.Base64
 
 -- | Create a template file from a stream of file/contents combinations.
 --
@@ -31,14 +32,14 @@
     => GInfConduit (FilePath, m ByteString) m ByteString
 createTemplate = awaitForever $ \(fp, getBS) -> do
     bs <- lift getBS
-    case runException $ yield bs $$ decodeUtf8 =$ sinkNull of
-        Left{} -> do
+    case yield bs $$ decodeUtf8 =$ sinkNull of
+        Nothing -> do
             yield "{-# START_FILE BASE64 "
             yield $ encodeUtf8 $ either id id $ toText fp
             yield " #-}\n"
-            yield $ B64.encode bs
+            yield $ B64.joinWith "\n" 76 $ B64.encode bs
             yield "\n"
-        Right{} -> do
+        Just _ -> do
             yield "{-# START_FILE "
             yield $ encodeUtf8 $ either id id $ toText fp
             yield " #-}\n"
@@ -73,15 +74,20 @@
                 Nothing -> lift $ monadThrow $ InvalidInput t
                 Just (fp', isBinary) -> do
                     let src
-                            | isBinary  = binaryLoop
+                            | isBinary  = binaryLoop =$= Data.Conduit.Base64.decode
                             | otherwise = textLoop True
                     src =$ perFile (fromText fp')
                     start
 
     binaryLoop = do
-        await >>= maybe (lift $ monadThrow BinaryLoopNeedsOneLine) go
+        await >>= maybe (return ()) go
       where
-        go = yield . B64.decodeLenient . encodeUtf8
+        go t =
+            case getFileName t of
+                Just{} -> leftover t
+                Nothing -> do
+                    yield $ encodeUtf8 t
+                    binaryLoop
     textLoop isFirst =
         await >>= maybe (return ()) go
       where
diff --git a/project-template.cabal b/project-template.cabal
--- a/project-template.cabal
+++ b/project-template.cabal
@@ -1,5 +1,5 @@
 name:                project-template
-version:             0.1.0.1
+version:             0.1.1
 synopsis:            Specify Haskell project templates and generate files
 description:         See initial blog post for explanation: <http://www.yesodweb.com/blog/2012/09/project-templates>
 homepage:            https://github.com/fpco/haskell-ide
@@ -16,6 +16,7 @@
   build-depends:       base                         >= 4          && < 5
                      , classy-prelude-conduit       >= 0.4
                      , base64-bytestring
+                     , base64-conduit
                      , system-filepath              >= 0.4
                      , system-fileio                >= 0.3
                      , text                         >= 0.11
@@ -23,6 +24,7 @@
                      , transformers                 >= 0.2
                      , mtl                          >= 2.0
                      , conduit                      >= 0.5.4
+                     , resourcet                    >= 0.4.3
   ghc-options:     -Wall
 
 test-suite test
@@ -36,6 +38,7 @@
                    , hspec >= 1.3
                    , transformers
                    , QuickCheck
+                   , base64-bytestring
     ghc-options:     -Wall
 
 source-repository head
diff --git a/test/Text/ProjectTemplateSpec.hs b/test/Text/ProjectTemplateSpec.hs
--- a/test/Text/ProjectTemplateSpec.hs
+++ b/test/Text/ProjectTemplateSpec.hs
@@ -9,6 +9,7 @@
 import Control.Monad.Trans.Writer (execWriter)
 import Test.QuickCheck.Arbitrary
 import Data.Char (isAlphaNum)
+import qualified Data.ByteString.Base64 as B64
 
 spec :: Spec
 spec = do
@@ -22,6 +23,13 @@
                      =$ unpackTemplate receiveMem id
                 m'' = pack $ map (second $ concat . toChunks) $ unpack m'
              in if m == m'' then True else error (show m'')
+    describe "binaries" $ do
+        prop "works with multilines" $ \words ->
+            let bs = pack words
+                encoded = B64.joinWith "\n" 5 $ B64.encode bs
+                content = "{-# START_FILE BASE64 foo #-}\n" ++ encoded
+                m = execWriter $ runExceptionT_ $ yield content $$ unpackTemplate receiveMem id
+             in lookup "foo" m == Just (fromChunks [bs])
 
 newtype Helper = Helper (Map FilePath ByteString)
     deriving (Show, Eq)
