Simplify encoding/decoding of numpy scalars.