BUG: optimize: fix issues related to line searches

This PR does the following:

- Deal properly with failing line searches, don't update variables spuriously.
- Convert fmin_ncg to use wolfe criterion (see [Trac #1778](http://projects.scipy.org/scipy/ticket/1778)).
- Clean up some magic numbers away from the code. Having `old_old_fval >> old_fval` results to initial step length of 1.0. However, `old_old_fval is None` achieves the same.
- Make `line_search_wolfe2` to actually signal a failure if it doesn't manage to find a suitable step length. Previously, it would just return some small number in the case of a failure.

The code is unfortunately a bit light on tests, so some careful review is warranted here.