Samsung reports improved profit as its chip business losses narrow