Lorenzo wins in Valencia and Rossi takes third on Yamaha farewell