Replace type(value) with isinstance().

This should now work for unicode strings and things like
numpy.float64().
Using a different approach for _bool()

The approach in previous changeset (37a5d9c) didn't
work for things like numpy.float32 or numpy.int32.
This one is easier and more general.