Adding a pixel_idx function to compute index of the B value of a pixel

Now use this to index into the arrays for get/set instead of recomputing the
index each time.