Fix serialize_number problems with gmpy