Electrolysis and electrosynthesis of organic compounds