Generalized the type of safeGetPixel