Added elem_size checks

Prevents a common cause of segfaults - a type mismatch between the
buffer_t passed in and the type expected inside the halide pipeline.