In-kind transfers, self-selection and optimal tax policy