I think this below works. It seems to be the fastest too.
Unfortunately putmask seemed to want a contiguous array, so I changed
that with the line:
array_new = Numeric.array(array)
Numeric is a bit weird sometimes.
def replace_color(pic, oldcolor, newcolor):
oldcolor_mapped = pic.map_rgb(oldcolor)
newcolor_mapped = pic.map_rgb(newcolor)
array = pygame.surfarray.pixels2d(pic)
array_new = Numeric.array(array)
mask = Numeric.where(array_new == oldcolor_mapped, 1, 0)
Numeric.putmask(array_new, mask, newcolor_mapped)