py: Fix mp_get_buffer, and use it in more places.

Must use mp_obj_get_type to get the type of an object.  Can't assume
mp_obj_t is castable to mp_obj_base_t.