Mode Matching for a lossy pillbox