Serialization: fix unnecessary conversions for int/bool values

Not sure how I missed "PyBytes_FromFormat" before.