Ultraviolet and optical observations of OB associations in M31