Index: src/java/org/apache/lucene/store/BufferedIndexOutput.java
===================================================================
--- src/java/org/apache/lucene/store/BufferedIndexOutput.java	(revision 290385)
+++ src/java/org/apache/lucene/store/BufferedIndexOutput.java	(working copy)
@@ -41,8 +41,27 @@
    * @see IndexInput#readBytes(byte[],int,int)
    */
   public void writeBytes(byte[] b, int length) throws IOException {
-    for (int i = 0; i < length; i++)
-      writeByte(b[i]);
+    if (bufferPosition > 0) // flush buffer
+      flush();
+
+    if (length < BUFFER_SIZE) {
+      flushBuffer(b, length);
+      bufferStart += length;
+    } else {
+      int pos = 0;
+      int size;
+      while (pos < length) {
+        if (length - pos < BUFFER_SIZE) {
+          size = length - pos;
+        } else {
+          size = BUFFER_SIZE;
+        }
+        System.arraycopy(b, pos, buffer, 0, size);
+        pos += size;
+        flushBuffer(buffer, size);
+        bufferStart += size;
+      }
+    }
   }
 
   /** Forces any buffered output to be written. */
