Pickle and Unpickle theano functions

Added a test case to verify if pickle and unpickle a compiled theano function works.
Passed.

This is the follow up of gh-1945
Which is why I think this should be split in two.  We can make the pickling fixes first and then work on a cache.