Before replacing the master cylinder I would plug the outlet on the master cylinder to the rear brakes. If air is coming in via the master cylinder you will have the same symptons as before. If not, the trouble will be in the rear brake lines, hoses, or wheel cylinders. Just a suggestion. Hope you find the problem.