Fix crashes related to sparse

Still need to fix CData on python 3. do not merge yet.

See [theano-users] Error computing gradient of sparse sum (sp_sum)