Method for producing thin films