private void writeNumber(long value) throws IOException {
        byte firstByte = 0;
        byte mask = (byte) 0x80;
        int i;
        for (i = 0; i < 8; i++) {
            if (value < ((((long) (1)) << (7 * (i + 1))))) {
                firstByte |= ((byte) (value >> (8 * i)));
                break;
            }
            firstByte |= mask;
            mask >>= 1;
        }
        writeByte(firstByte);
        for (; i > 0; i--) {
            writeByte((byte) value);
            value >>= 8;
        }

    }