That wont work. Assuming that the reason for the bad plight of the cows is that the worse treatment is more profitable, not that the farmer is sadistic, the farmer has two options: A) Conventional at cost X per unit and B) Animal friendly at cost X+N per unit. Now, to achieve your goal, you tax A at at least N per unit and subsidise B at the same rate. Now, people start buying B in favour of A and the farmers shift production to B, and soon production of A ceases - but as this is the object of the taxation, the tax revenue disappear and with it your budget for subsidising B. B now costs X+N.