A painting that was stolen from a museum in Scotland has been returned more than 30 years after it went missing.