improved implementation of getPixel(..)