protected static void setBufferByte(uint[] buffer, int offset, byte val)
{
int index = offset / 4;
int position = offset % 4;
int bit_offset = 8 * position;
buffer[index] &= (uint)(0xFF << bit_offset) ^ 0xFFFFFFFF;
buffer[index] |= (uint)val << bit_offset;
}