public void setBuffer()
   {
      int tagHeaderSize = ID3V2_3_TAG_HEADER_STANDARD_SIZE + (extendedHeaderPresent ? ID3V2_3_TAG_HEADER_EXTENDED_HEADER_DEFAULT_SIZE  : 0) +
                                                             (CRCDataPresent        ? ID3v2_3_TAG_HEADER_EXTENDED_HEADER_CRC_DATA_SIZE : 0);

      header = new byte[tagHeaderSize];
      header[0] = 0x49;   // I
      header[1] = 0x44;   // D
      header[2] = 0x33;   // 3
      header[3] = 0x03;   // version 3
      header[4] = 0x00;   //         0
      header[5] = (byte)(unsynchronization     ? header[5] | ID3v2_3_TAG_HEADER_UNSYNCHRONIZATION_MASK       : header[5] & ~ID3v2_3_TAG_HEADER_UNSYNCHRONIZATION_MASK      );
      header[5] = (byte)(extendedHeaderPresent ? header[5] | ID3v2_3_TAG_HEADER_EXTENDED_HEADER_PRESENT_MASK : header[5] & ~ID3v2_3_TAG_HEADER_EXTENDED_HEADER_PRESENT_MASK);
      header[5] = (byte)(experimentalIndicator ? header[5] | ID3v2_3_TAG_HEADER_EXPERIMENTAL_INDICATOR_MASK  : header[5] & ~ID3v2_3_TAG_HEADER_EXPERIMENTAL_INDICATOR_MASK );
      header[6] = (byte)((tagSize & 0x0FE00000) >> 21);
      header[7] = (byte)((tagSize & 0x001FC000) >> 14);
      header[8] = (byte)((tagSize & 0x00003F80) >> 7);
      header[9] = (byte) (tagSize & 0x0000007F);

      // if there are any additional fields, then write them to the raw binary header
      if (header.length != ID3V2_3_TAG_HEADER_STANDARD_SIZE)
      {
         extendedHeaderSize = CRCDataPresent ? 10 : 6;

         header[10] = (byte)((extendedHeaderSize & 0xFF000000) >> 24);
         header[11] = (byte)((extendedHeaderSize & 0x00FF0000) >> 16);
         header[12] = (byte)((extendedHeaderSize & 0x0000FF00) >> 8);
         header[13] = (byte) (extendedHeaderSize & 0x000000FF);
         header[14] =        (CRCDataPresent ? ID3v2_3_TAG_HEADER_EXTENDED_HEADER_CRC_MASK : 0x00);
         header[15] = 0x00;
         header[16] = (byte)((paddingSize & 0xFF000000) >> 24);
         header[17] = (byte)((paddingSize & 0x00FF0000) >> 16);
         header[18] = (byte)((paddingSize & 0x0000FF00) >> 8);
         header[19] = (byte) (paddingSize & 0x000000FF);

         if (CRCDataPresent)
            System.arraycopy(CRCData, 0, header, 20, CRCData.length);
      }
      dirty = false;
   }