diff --git a/bits/23_binutils.js b/bits/23_binutils.js
index b9f6e65..534087b 100644
--- a/bits/23_binutils.js
+++ b/bits/23_binutils.js
@@ -25,7 +25,7 @@ function write_double_le(b/*:RawBytes|CFBlob*/, v/*:number*/, idx/*:number*/) {
 	b[idx + 7] = (e >> 4) | bs;
 }
 
-var __toBuffer = function(bufs) { var x = []; for(var i = 0; i < bufs[0].length; ++i) { x.push.apply(x, bufs[0][i]); } return x; };
+var __toBuffer = function(bufs/*:Array<any>*/) { var x=[],w=10240; for(var i=0;i<bufs[0].length;++i) for(var j=0,L=bufs[0][i].length;j<L;j+=w) x.push.apply(x, bufs[0][i].slice(j,j+w)); return x; };
 var ___toBuffer = __toBuffer;
 var __utf16le = function(b/*:RawBytes|CFBlob*/,s/*:number*/,e/*:number*/)/*:string*/ { var ss/*:Array<string>*/=[]; for(var i=s; i<e; i+=2) ss.push(String.fromCharCode(__readUInt16LE(b,i))); return ss.join("").replace(chr0,''); };
 var ___utf16le = __utf16le;
diff --git a/test.js b/test.js
index 768bea8..5c5d2e3 100644
--- a/test.js
+++ b/test.js
@@ -2033,6 +2033,21 @@ describe('corner cases', function() {
 	it('codepage', function() {
 		X.read(fs.readFileSync(dir + "biff5/number_format_greek.xls"), {type:TYPE});
 	});
+	it('large binary files', function() {
+		var data = [["Row Number"]];
+		for(var j = 0; j < 19; ++j) data[0].push("Column " + j+1);
+		for(var i = 0; i < 499; ++i) {
+			var o = ["Row " + i];
+			for(j = 0; j < 19; ++j) o.push(i + j);
+			data.push(o);
+		}
+		var ws = X.utils.aoa_to_sheet(data);
+		var wb = { Sheets:{ Sheet1: ws }, SheetNames: ["Sheet1"] };
+		var type = "binary";
+		["xlsb", "biff8", "biff5", "biff2"].forEach(function(btype) {
+			void X.read(X.write(wb, {bookType:btype, type:type}), {type:type});
+		});
+	});
 });
 
 describe('encryption', function() {
diff --git a/tests/core.js b/tests/core.js
index 768bea8..5c5d2e3 100644
--- a/tests/core.js
+++ b/tests/core.js
@@ -2033,6 +2033,21 @@ describe('corner cases', function() {
 	it('codepage', function() {
 		X.read(fs.readFileSync(dir + "biff5/number_format_greek.xls"), {type:TYPE});
 	});
+	it('large binary files', function() {
+		var data = [["Row Number"]];
+		for(var j = 0; j < 19; ++j) data[0].push("Column " + j+1);
+		for(var i = 0; i < 499; ++i) {
+			var o = ["Row " + i];
+			for(j = 0; j < 19; ++j) o.push(i + j);
+			data.push(o);
+		}
+		var ws = X.utils.aoa_to_sheet(data);
+		var wb = { Sheets:{ Sheet1: ws }, SheetNames: ["Sheet1"] };
+		var type = "binary";
+		["xlsb", "biff8", "biff5", "biff2"].forEach(function(btype) {
+			void X.read(X.write(wb, {bookType:btype, type:type}), {type:type});
+		});
+	});
 });
 
 describe('encryption', function() {
diff --git a/xlsx.flow.js b/xlsx.flow.js
index b4a68be..c65c744 100644
--- a/xlsx.flow.js
+++ b/xlsx.flow.js
@@ -2327,7 +2327,7 @@ function write_double_le(b/*:RawBytes|CFBlob*/, v/*:number*/, idx/*:number*/) {
 	b[idx + 7] = (e >> 4) | bs;
 }
 
-var __toBuffer = function(bufs) { var x = []; for(var i = 0; i < bufs[0].length; ++i) { x.push.apply(x, bufs[0][i]); } return x; };
+var __toBuffer = function(bufs/*:Array<any>*/) { var x=[],w=10240; for(var i=0;i<bufs[0].length;++i) for(var j=0,L=bufs[0][i].length;j<L;j+=w) x.push.apply(x, bufs[0][i].slice(j,j+w)); return x; };
 var ___toBuffer = __toBuffer;
 var __utf16le = function(b/*:RawBytes|CFBlob*/,s/*:number*/,e/*:number*/)/*:string*/ { var ss/*:Array<string>*/=[]; for(var i=s; i<e; i+=2) ss.push(String.fromCharCode(__readUInt16LE(b,i))); return ss.join("").replace(chr0,''); };
 var ___utf16le = __utf16le;
diff --git a/xlsx.js b/xlsx.js
index c768240..11931df 100644
--- a/xlsx.js
+++ b/xlsx.js
@@ -2255,7 +2255,7 @@ function write_double_le(b, v, idx) {
 	b[idx + 7] = (e >> 4) | bs;
 }
 
-var __toBuffer = function(bufs) { var x = []; for(var i = 0; i < bufs[0].length; ++i) { x.push.apply(x, bufs[0][i]); } return x; };
+var __toBuffer = function(bufs) { var x=[],w=10240; for(var i=0;i<bufs[0].length;++i) for(var j=0,L=bufs[0][i].length;j<L;j+=w) x.push.apply(x, bufs[0][i].slice(j,j+w)); return x; };
 var ___toBuffer = __toBuffer;
 var __utf16le = function(b,s,e) { var ss=[]; for(var i=s; i<e; i+=2) ss.push(String.fromCharCode(__readUInt16LE(b,i))); return ss.join("").replace(chr0,''); };
 var ___utf16le = __utf16le;