Add integer encoding

Also, take advantage of ``typemin`` and ``typemax``.