I want to swap the handlebars for a different pair. I have hydraulic brakes. When i remove the master cylinders from the old handlebars is it necessary to keep them upright, or keep them above the brake callipers? Is there anything else I should be wary of during this procedure?
There should be no problem turning your master cylinders upside down for a short time.
I've found that the worst thing that happens is that it might take a bit of pumping action after you right the master cylinders to get them working as expected again but generally even that is not needed.
If there is air in the system it can require bleeding but you'd already be having issues with the brakes if that were the case.