I think JaWib is right. Assuming you want to check all eight bits per byte, you need another loop. And if you want to print the most sigficicant bit first (instead of the least significant bit), just change the bit array (old code commented).
Code:
const unsigned int bit[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
int binValue, j;
int byte = 0;
for (int k=0; k < imageLength; k++)
{
for (int i=0; i < imageWidth; i++)
{
//if(j > 7) j = 0;
for (j=0; j<8; j++)
{
//binValue = ((buf[i] & bit[j]) ? 1 : 0 );
binValue = ((buf[byte] & bit[j]) ? 1 : 0 );
cout << binValue;
}
cout << " ";
byte++;
//j++;
}
cout << endl;
}