Facebook revenue rises 40% as mobile ad sales strengthen