Tsonga beats Shapovalov after epic