State Preparation by Photon Filtering