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.
there's probably a more duck-typey way to do this. but it's not worth the time i think. i.e., just expecting attributes to exist etc...