Add encoder to handle masked numbers.

@chriddyp , it'd be cool to get your input on this one, I think you wrote the encoders in here originally. I need to write a test before we pass this off still too.
this is right (i think) but the logic might be made clearer with `()`

`if x and (y is z):`