High-contrast fluorescence imaging in fixed and living cells using optimized optical switches