fix to clone functionality of theano

Refers to the bug reported by Akio Takano on the mailing list. The problem refers to the case when one tries to replace x with a function of x, f(x). 

The fix implies first replacing x with some tmp_x and then tmp_x with f(x).