Former champion Serena Williams earned a hard fought win against Ash Barty