Preparation of thiols, sulfides, hydropolysulfides or polysulfides