I've seen that IndexOB Auto pass is not working as I think is correct, maybe i'm wrong, but every object should get an unique ID, but I've seen that sometimes 2 different objects get the same Id and makes difficult to became a viable mask solution. (Sometimes when they one in front of the other, which is worse).
I attach the sample file.
Maybe the same occurs with IndexMat Auto pass.
Edit: Use IndexOB Auto pass with a color pass.
Change the issue to request an auto Object id and auto Material id passes on integer image file.