Kantorovich duality for general transport costs and applications