Theano interface change

close gh-492 as it include those commit and add the missing commit to finish the fix.

Thanks @mdenil to start this fix.