Fix broadcasting for elemwise.
Fix problems found by Fred.
Make sure output arrays are of the right dtype.