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.
the first time i looked at this, it took me a second to grok. wanna add a quick bit of documentation :)