population count, see http://en.wikipedia.org/wiki/Hamming_weight
this code can take some shortcuts as we want to count bytes.